<?php

namespace app\api\controller;

use app\admin\logic\article\ArticleCategoryLogic;
use app\admin\logic\setting\BannerLogic;
use app\admin\logic\system\SystemConfigLogic;
use app\basic\ApiController;
use hg\apidoc\annotation as Apidoc;
use support\Request;

/**
 * @Apidoc\Title("首页接口")
 */
class IndexController extends ApiController
{
    // 无需登录的接口,*表示全部
    protected $noNeedLogin = ['*'];


    /**
     * @Apidoc\Title("获取轮播图")
     * @Apidoc\Method("POST")
     */
    public function getBannerLists(Request $request)
    {
        $list = (new BannerLogic())->where(['status'=>1])->order("sort","desc")->select();
        return $this->success($list);
    }

    /**
     * @Apidoc\Title("获取金刚区分类")
     * @Apidoc\Method("POST")
     */
    public function getCategoryLists()
    {
        $list = (new ArticleCategoryLogic())->where(['status'=>1,'parent_id'=>0])->order("sort","desc")->limit(0,10)->field("id,category_name,image")->select();
        return $this->success($list);
    }

     /**
     * @Apidoc\Title("公众号关注配置")
     * @Apidoc\Method("POST")
     */
    public function getAttentionInfo()
    {
        $systemConfigLogic = new SystemConfigLogic();
        $systemInfo = $systemConfigLogic->getConfigByGroup('attention');
        return $this->success($systemInfo);
    }

   /**
     * @Apidoc\Title("站点基础配置")
     * @Apidoc\Method("POST")
     */
    public function initSetting()
    {
        $systemConfigLogic = new SystemConfigLogic();
        $systemInfo = $systemConfigLogic->getConfigByGroup('site_config');
        return $this->success($systemInfo);
    }

    /**
     * @Apidoc\Title("客服信息接口")
     * @Apidoc\Method("POST")
     */
    public function getCustomer()
    {
        $systemConfigLogic = new SystemConfigLogic();
        $systemInfo = $systemConfigLogic->getConfigByGroup('customer');
        return $this->success($systemInfo);
    }
    
        /**
     * @Apidoc\Title("协议接口")
     * @Apidoc\Method("POST")
     */
    public function getAgreement()
    {
        $systemConfigLogic = new SystemConfigLogic();
        $systemInfo = $systemConfigLogic->getConfigByGroup('agreement');
        return $this->success($systemInfo);
    }



}